package com.naiterui.ehp.bs.b2c.order.controller.inner;

import com.naiterui.ehp.bp.constants.SwaggerTag;
import com.naiterui.ehp.bp.support.exception.BaseExceptionCodes;
import com.naiterui.ehp.bp.support.exception.BusinessException;
import com.naiterui.ehp.bs.b2c.order.bo.LogisticsInfoBO;
import com.naiterui.ehp.bs.b2c.order.service.ILogisticsTraceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * @author luao
 * @date 2022/4/27 3:58 PM
 **/
@Api(tags = {SwaggerTag.INNER_API + SwaggerTag.SELF_INSPECT})
@RestController
@RequestMapping("b2c/inner/self/inspect")
public class InnerSelfInspectController {

    @Autowired
    @Qualifier("kudi100")
    private ILogisticsTraceService logisticsTraceService;

    @ApiOperation(value = "快递100自检")
    @GetMapping("/kuaidi100")
    public void kuaidi100(String deliveryId, String companyCode) throws BusinessException {
        LogisticsInfoBO logisticsInfoBO = logisticsTraceService.getTrace(deliveryId, companyCode, null);
        if (logisticsInfoBO == null || logisticsInfoBO.getStatus() == LogisticsInfoBO.STATUS_NONE) {
            throw new BusinessException(BaseExceptionCodes.FAILED, "快递100自检失败");
        }
    }
}
